package com.qyer.lxp.common.framework.contants;

/**
 * 异常错误消息类
 * Created by jiangping on 16/5/20.
 */
public enum ErrorMessageEnum {

    COMMONS_SERVICE_001("COMMONS_SERVICE_001","未知异常"),
    COMMONS_SERVICE_002("COMMONS_SERVICE_002","读取request出错"),
    COMMONS_SERVICE_004("COMMONS_SERVICE_004","调用服务出错"),
    COMMONS_SERVICE_006("COMMONS_SERVICE_006","没有该接口"),
    COMMONS_SERVICE_007("COMMONS_SERVICE_007","签名验证服务失败"),
    COMMONS_SERVICE_008("COMMONS_SERVICE_008","验证签名无效"),
    COMMONS_SERVICE_009("COMMONS_SERVICE_009","请求没有签名信息");

    private String code;
    private String message;

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    ErrorMessageEnum(String code, String message){
        this.code = code;
        this.message = message;
    }

    /**
     * 返回异常信息
     * @param code
     * @return
     */
    public static String getErrorMessage(String code){
        if(null == code || "".equals(code.trim())){
            return COMMONS_SERVICE_001.getMessage();
        }
        for(ErrorMessageEnum errorMessageEnum : ErrorMessageEnum.values()){
            if(errorMessageEnum.getCode().equals(code)){
                return errorMessageEnum.getMessage();
            }
        }
        return COMMONS_SERVICE_001.getMessage();
    }

}
